-
-
Notifications
You must be signed in to change notification settings - Fork 38
Avoid recomputing tree when a new root node is added #194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Avoid recomputing tree when a new root node is added #194
Conversation
|
Hi @fabiocaccamo, when you have some time, could you please review this? |
8af66cf to
b12056d
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #194 +/- ##
==========================================
+ Coverage 91.14% 91.21% +0.07%
==========================================
Files 11 11
Lines 700 706 +6
==========================================
+ Hits 638 644 +6
Misses 62 62
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Skip tree recomputation when the newly added node is a separate root. - Updated `is_last_child` to return False for root nodes without children. - Adjusted tests for sibling count and presence accordingly. - Commented out unused `get_tree_dump` method.
b12056d to
24e0b08
Compare
|
@p-r-a-v-i-n the PR should be 100% backward compatible, please do not change existing tests. |
|
@fabiocaccamo I can understand your concern. I have change only this part in testing. where I was making sure that nodes can be siblings of each other only if they share common parent if not then they don't have any siblings. |
|
@p-r-a-v-i-n for example I used this library for managing menu items on multiple websites, menu items are considered as siblings, even if they don't share the same parent (or yes, If you can adapt your changes avoiding to change existing tests I would be happy to merge it! |
|
totally fine. but I would still argu that we should go for this approach for long run. this won't impact on anything that exist related to django-tree node. anyway I will work on it. may be i can find a better approach with backward compatibility. |
name: Pull request
about: Avoid recompute of the entire tree when new root node was added.
assignees: fabiocaccamo
Describe your changes
Previously, whenever a new root node (i.e. a node with no parent) was added, the entire tree structure was recomputed. This was redundant and negatively impacted performance.
With this change:
Related issue
closes #45
Checklist before requesting a review
I have performed a self-review of my code.
I have added or updated tests for the proposed changes.
I have run the test suite and confirmed that all tests pass.